﻿using System.ComponentModel.DataAnnotations;

namespace MvcCart.Models
{
    public class Cart
    {
        [Required(ErrorMessage = "购物车id必填")]
        [StringLength(20, MinimumLength = 1, ErrorMessage = "1-20个字符")]
        [Display(Name = "购物车id")]
        public string? cartid { get; set; }



        [Required(ErrorMessage = "商品id必填")]
        [StringLength(20, MinimumLength = 1, ErrorMessage = "1-20个字符")]
        [Display(Name = "商品id")]
        public string? productid { get; set; }



        [Required(ErrorMessage = "商品数量必填")]
        [Range(1, 100, ErrorMessage = "1-100之间")]
        [Display(Name = "商品数量")]
        public int productnum { get; set; }



        [Required(ErrorMessage = "商品价格必填")]
        [Range(1, 100, ErrorMessage = "1-100之间")]
        [Display(Name = "商品价格")]
        public int price { get; set; }



        [Required(ErrorMessage = "用户id必填")]
        [StringLength(20, MinimumLength = 1, ErrorMessage = "1-20个字符")]
        [Display(Name = "用户id")]
        public string? userid { get; set; }



        [Required(ErrorMessage = "创建日期必填")]
        [Display(Name = "创建时间")]
        [DataType(DataType.Date)]
        public DateTime? createtime { get; set; }
    }
}
